package com.qf.auth.api;

import com.qf.auth.service.TenantService;
import com.qf.common.bean.R;
import com.qf.common.dto.TenantDto;
import com.qf.common.model.QfTenant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 千锋健哥
 */
@RestController
@RequestMapping("/auth/tenant")
public class TenantController {

    @Autowired
    private TenantService tenantService;

    /**
     * 判断租户用户名是否重复
     * @param name
     * @return
     */
    @GetMapping("/isexist")
    public R<Boolean> isexist(String name) {
        R<Boolean> result = tenantService.isexist(name);
        return result;
    }

    /**
     * 租户注册
     * @param dto
     * @return
     */
    @PostMapping("/regist")
    public R<QfTenant> regist(@RequestBody TenantDto dto) {
        R<QfTenant> result = tenantService.add(dto);
        return result;
    }

    /**
     * 登录
     * @return
     */
    @PostMapping("/login")
    public R<String> login(@RequestBody TenantDto dto) {
        R<String> r = tenantService.login(dto);
        return r;
    }
}
